package com.chw.api.menu;

import javax.servlet.http.HttpServletRequest;

import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.chw.common.ServiceData;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

/**
 * spring mvc控制类
 * 
 * @author Admin
 *
 */
@Controller
@RequestMapping("/sysmenu")
@Api(value = "/sysmenu")
public class SysMenuController {

	/**
	 * 根据菜单ID获取菜单对象
	 * 
	 * @param request
	 * @param id
	 *            菜单ID
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/getSysMenuById.do", method = RequestMethod.GET, consumes = MediaType.ALL_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
	@ResponseBody
	@ApiOperation(value = "getSysMenuById", httpMethod = "GET", response = ServiceData.class, notes = "根据菜单ID获取菜单对象")
	public ServiceData get(HttpServletRequest request, @ApiParam(value = "id", required = true) String id)
			throws Exception {
		// 返回统一的服务端数据
		ServiceData ret = new ServiceData();
		// 业务操作可以不捕获异常,由统一的异常处理方法处理
		ret.setCode(request, ServiceData.RetCode.Success);
		ret.setBo(new SysMenu().initMenu());
		return ret;
	}

	/**
	 * 根据查询条件获取菜单对象
	 * 
	 * @param request
	 * @param sysMenu
	 *            菜单对象
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/findSysMenu.do", method = RequestMethod.GET, consumes = MediaType.ALL_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
	@ResponseBody
	// @ApiOperation(value = "findSysMenu", httpMethod = "GET", response =
	// ServiceData.class, notes = "根据查询条件获取菜单对象")
	// @RequestBody
	public ServiceData find(HttpServletRequest request, SysMenu sysMenu) throws Exception {
		// 返回统一的服务端数据
		ServiceData ret = new ServiceData();
		// 业务操作可以不捕获异常,由统一的异常处理方法处理
		ret.setCode(request, ServiceData.RetCode.Success);
		ret.setBo(new SysMenu().initMenu());
		return ret;
	}

	/**
	 * 判断是否有子菜单
	 * 
	 * @param request
	 * @param id
	 *            菜单ID
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/hasSubSysMenu.do", method = RequestMethod.GET, consumes = MediaType.ALL_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
	@ResponseBody
	// @ApiOperation(value = "hasSubSysMenu", httpMethod = "GET", response =
	// ServiceData.class, notes = "判断是否有子菜单")
	// @ApiParam(value = "id", required = true)
	public ServiceData hasSubMenu(HttpServletRequest request, String id) throws Exception {
		// 返回统一的服务端数据
		ServiceData ret = new ServiceData();
		// 业务操作可以不捕获异常,由统一的异常处理方法处理
		ret.setCode(request, ServiceData.RetCode.Success);
		ret.setBo(new SysMenu().initMenu());
		return ret;
	}

	/**
	 * 分页查询菜单
	 * 
	 * @param request
	 * @param sysMenu
	 *            菜单对象
	 * @param currentPage
	 *            当前页码
	 * @param pageSize
	 *            每页大小
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/pageSysMenu.do", method = RequestMethod.POST, consumes = MediaType.ALL_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
	@ResponseBody
	// @ApiOperation(value = "pageSysMenu", httpMethod = "POST", response =
	// ServiceData.class, notes = "分页查询菜单")
	// @RequestBody SysMenu sysMenu,
	// @ApiParam(value = "pageSize", required = true)
	// @ApiParam(value = "currentPage", required = true)
	public ServiceData page(HttpServletRequest request, SysMenu sysMenu, Integer currentPage, Integer pageSize)
			throws Exception {
		// 返回统一的服务端数据
		ServiceData ret = new ServiceData();
		// 业务操作可以不捕获异常,由统一的异常处理方法处理
		ret.setCode(request, ServiceData.RetCode.Success);
		ret.setBo(new SysMenu().initMenu());
		return ret;
	}

	/**
	 * 更新菜单状态
	 * 
	 * @param request
	 * @param id
	 *            菜单ID
	 * @param status
	 *            菜单状态
	 * @throws Exception
	 */
	@RequestMapping(value = "/updateStatusSysMenu.do", method = RequestMethod.POST, consumes = MediaType.ALL_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
	@ResponseBody
	// @ApiOperation(value = "updateStatusSysMenu", httpMethod = "POST", notes =
	// "更新菜单状态")
	// @ApiParam(value = "id", required = true)
	// @ApiParam(value = "status", required = true)
	public void updateStatus(HttpServletRequest request, String id, String status) throws Exception {
		// 业务操作可以不捕获异常,由统一的异常处理方法处理
	}

	/**
	 * 删除菜单
	 * 
	 * @param request
	 * @param id
	 *            菜单ID
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/deleteSysMenu.do", method = RequestMethod.POST, consumes = MediaType.ALL_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
	@ResponseBody
	// @ApiOperation(value = "deleteSysMenu", httpMethod = "POST", response =
	// ServiceData.class, notes = "删除菜单")
	// @ApiParam(value = "id", required = true)
	public ServiceData delete(HttpServletRequest request, String id) throws Exception {
		// 返回统一的服务端数据
		ServiceData ret = new ServiceData();
		// 业务操作可以不捕获异常,由统一的异常处理方法处理
		ret.setCode(request, ServiceData.RetCode.Success);
		return ret;
	}

	/**
	 * 保存菜单
	 * 
	 * @param request
	 * @param sysMenu
	 *            菜单对象
	 * @return
	 * @throws Exception
	 */
	@RequestMapping(value = "/saveOrUpdateSysMenu.do", method = RequestMethod.POST, consumes = MediaType.ALL_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
	@ResponseBody
	// @ApiOperation(value = "saveOrUpdateSysMenu", httpMethod = "POST",
	// response = ServiceData.class, notes = "保存菜单")
	// @RequestBody
	public ServiceData saveOrUpdate(HttpServletRequest request, SysMenu sysMenu) throws Exception {
		// 返回统一的服务端数据
		ServiceData ret = new ServiceData();
		// 业务操作可以不捕获异常,由统一的异常处理方法处理
		ret.setCode(request, ServiceData.RetCode.Success);
		return ret;
	}
}